package com.yoyo.ad.utils;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.telephony.TelephonyManager;

import androidx.core.app.ActivityCompat;

import static com.yoyo.ad.api.YoYoConfig.SYSTEM_APP;

/**
 * create by huanzw
 * 系统工具类
 */
public class SystemUtil {
    //获取手机型号
    public static String getSystemModel() {
        return android.os.Build.MODEL;
    }

    //是否是7.0及以上应用
    public static boolean isVersionMUp() {
        if (SYSTEM_APP) {
            return Build.VERSION.SDK_INT > Build.VERSION_CODES.M;
        } else {
            return false;
        }
    }

    //获取手机imei值
    public static String getIMEI(Context ctx) {
        TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Activity.TELEPHONY_SERVICE);
        if (tm != null) {
            if (ActivityCompat.checkSelfPermission(ctx, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
                return tm.getDeviceId();
            }
            return tm.getDeviceId();
        }
        return null;
    }
}
